
//
//  MainViewController.m
//  2018.04.03-MasonryExercise
//
//  Created by lsp's mac pro on 2018/4/3.
//  Copyright © 2018年 lsp's mac pro. All rights reserved.
//

#import "MainViewController.h"
#import "MainTableViewCell.h"

@interface MainViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor lightGrayColor];
    [self setUpUi];
    
    
}
-(void)setUpUi{
    UIView*headerView=[[UIView alloc]init];
    headerView.backgroundColor=[UIColor yellowColor];
    [self.view addSubview:headerView];
    
    
    UITableView*tabelViewTest=[[UITableView alloc]init];
    tabelViewTest.delegate=self;
    tabelViewTest.dataSource=self;
    UIRefreshControl*refreshControll=[[UIRefreshControl alloc]init];
    [tabelViewTest addSubview:refreshControll];
    
    [self.view addSubview:tabelViewTest];
    
    [headerView makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.equalTo(@100);
    }];
    
    [tabelViewTest makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return AdaptedWidth(100);
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString*str=@"cellId";
    MainTableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:str];
    
    if (cell==nil) {
        cell=[[MainTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
    }
    
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
